<?php
/** @var CuentaController $this */
/** @var Cuenta $model */
$this->pageTitle = Cuenta::label(2);
Util::tsRegisterAssetJs('admin.js');

$this->menu = array(
    array('label' => Yii::t('AweCrud.app', 'Create'), 'icon' => 'plus', 'url' => array('create'), 'visible' => (Util::checkAccess(array('action_cuenta_create')))),
    array('label' => Yii::t('app', 'Grupos'), 'icon' => 'archive', 'url' => array('grupo'), 'visible' => (Util::checkAccess(array('action_cuenta_grupo')))),
    array(
        'label' => 'Exportar', 'icon' => 'download-alt', 'url' => '#', 'items' => array(
            array('label' => 'Todos', 'url' => '#', 'linkOptions' => array(
                    'onclick' => 'ExporCont(true)',)),
            array('label' => 'Seleccionados', 'url' => '#', 'linkOptions' => array(
                    'onclick' => 'ExporCont(false)',))
        ), 'visible' => (Util::checkAccess(array('action_cuenta_exportExcel'))),
    ),
);
?>

<div class="widget orange">
    <div class="widget-title">
        <h4><i class="icon-briefcase"></i> <?php echo Yii::t('AweCrud.app', 'Manage') ?> <?php echo Cuenta::label(2) ?></h4>
        <span class="tools">
            <a href="javascript:;" class="icon-chevron-down"></a>
            <!--a href="javascript:;" class="icon-remove"></a-->
        </span>
    </div>

    <div class="widget-body">
        <?php
        $this->widget('ext.Truulo.TruuloModuleSearch', array(
            'model' => $model,
            'grid_id' => 'cuenta-grid',
        ));
        ?>
        <div style='overflow:auto'> 
            <?php
            $this->widget('ext.selgridview.BootSelGridView', array(
                'id' => 'cuenta-grid',
                'type' => 'striped bordered hover advance',
                "template" => "{items}{summary}{pager}",
                'dataProvider' => $model->activos()->search(),
                'afterAjaxUpdate' => 'function(id,data){ $(\'span.star-rating > input\').rating(); $(\'div .rating-cancel\').hide(); ratingCargaGrid();}',
                'selectableRows' => 2,
                'columns' => array(
                    array(
                        'class' => 'CCheckBoxColumn',
                    ),
                    array(
                        'name' => 'rating',
                        'type' => 'raw',
                        'value' => '$this->grid->controller->widget("CStarRating", array (
                        "name" => $data->id,
                        "id" => "rating_".$data->id,
                        "value" => $data->rating,
                        "allowEmpty" => false,
                        "maxRating" => 5,
                        "htmlOptions" => array("class"=>"star-rating"),
                        "callback"=>"js:function(){
                            rating($data->id);
                        }"
                    ), true)',
                        'headerHtmlOptions' => array('style' => 'width:85px;'),
                        'filter' => false,
                        'sortable' => true,
                        'header' => '<i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i>',
                        'visible' => Util::checkAccess(array("action_cuenta_rating"))
                    ),
                    array(
                        'name' => 'nombre',
                        'value' => 'CHtml::link($data->nombre, Yii::app()->createUrl("crm/cuenta/view",array("id"=>$data->id)))',
                        'type' => 'raw',
                    ),
                    array(
                        'header' => 'Teléfono',
                        'value' => '$data->telefonoPrincipal?$data->telefonoPrincipal:"<label class=\"text-info\">no registrado</label>"',
                        'type' => 'raw',
                    ),
                    array(
                        'name' => 'industria_id',
                        'value' => '$data->industria?$data->industria->nombre:null',
                    ),
                    array(
                        'name' => 'tipo',
                        'value' => '$data->tipoTexto',
                        'filter' => $model->tipoOpciones,
                    ),
                    array(
                        'name' => 'owner_id',
                        'value' => 'Yii::app()->user->um->loadUserById($data->owner_id)->username',
                    ),
                    array
                        
                        
                        (
                        'class' => 'CButtonColumn',
                        'template' => '{update} {delete}',
                        'buttons' => array(
                            'update' => array(
                                'label' => '<button class="btn btn-primary"><i class="icon-pencil"></i></button>',
                                'options' => array('title' => 'Actualizar'),
                                'imageUrl' => false,
                                'visible' => 'Util::checkAccess(array("action_cuenta_update"))'
                            ),
                            'delete' => array(
                                'label' => '<button class="btn btn-danger"><i class="icon-trash"></i></button>',
                                'options' => array('title' => 'Eliminar'),
                                'imageUrl' => false,
                                'visible' => 'Util::checkAccess(array("action_cuenta_delete"))'
                            ),
                        ),
                        'htmlOptions' => array(
                            'width' => '80px'
                        )
                    ),
                ),
            ));
            ?>
        </div>
    </div>
</div>
<form id="formId" method="post" target="blank">
    <input type="hidden" id="id_cuent" name="Cuentas">
</form>
